home *** CD-ROM | disk | FTP | other *** search
/ Macworld Expo - Develope…Central & Net Innovations / Developer Central and Net Innovators (MacWorld Expo) (January 1999).iso / Developer Central / Metrowerks CodeWarrior / CodeWarrior Pro 4 Release Notes / Compiler Notes / CW Mac PPC Notes 2.2.txt < prev    next >
Encoding:
Text File  |  1998-09-09  |  10.5 KB  |  301 lines  |  [TEXT/CWIE]

  1. ========================================================================
  2. Metrowerks PPC Release Notes
  3. ========================================================================
  4.  
  5. Version: 2.2 ( __MWERKS__ == 0x2200 )
  6. Date:    August 25, 1998
  7. Author:  Bob Campbell
  8.  
  9. ========================================================================
  10. New Features in this Version
  11. ========================================================================
  12.  
  13. *  The global optimizer is now controled by the Global Optimizations
  14.    panel and is set by levels (0-4). There are pragmas to disable
  15.    some optimizations if needed. The following pragmas work for
  16.    PowerPC, 68K and x86:
  17.  
  18.    #pragma opt_common_subs --> control common subexpression elimination
  19.    #pragma opt_loop_invariants --> control loop invariant removal
  20.    #pragma opt_strength_reduction --> control loop strenght reduction
  21.    #pragma opt_propagation --> control copy and constant propagation
  22.    #pragma opt_lifetimes --> control lifetime analysis
  23.    #pragma opt_deadcode --> control dead code elimination
  24.    #pragma opt_dead_assignments --> remove dead assignments
  25.  
  26.    In addition there are 3 new powerpc specific pragmas which default
  27.    to the following (more details on these below).
  28.  
  29.    #pragma ppc_unroll_instructions_limit 100
  30.    #pragma ppc_unroll_factor_limit 10
  31.    #pragma ppc_unroll_speculative off
  32.  
  33.  
  34. *  Implement branchless compares which don't use the condition code
  35.    fields. These optmizations are explained in "The PowerPC(tm)
  36.    Compiler Writer's Guide" Appendix D (D.1 Comparisons and
  37.    Comparisons Aginst Zero)
  38.  
  39.    a = b == c;
  40.  
  41. *  Implement "!" with-out branches if the expression is not a "&&" or
  42.    "||". In effect "!" for a value in a register is the same as r == 0.
  43.    The code generated is:
  44.  
  45.    cntlwz Ry,Rvalue
  46.    srwi   Rresult,Ry
  47.  
  48. *  Check for the "!!" case (which sometimes happens with inlining)
  49.    !(!(x)) is the same as (x) iff x is a logical expression.
  50.  
  51. *  Optimize 16 or 8 bit math to remove the EXTS[HB] or RLWINM instructions
  52.    when it can be proven that they are not needed (LHZ does not need to be
  53.    followed by a RLWINM, and LHA does not need to be followed by a EXTSH
  54.    etc.)
  55.  
  56. *  Extensive Optimization Improvements
  57.    + Loop unrolling for fixed count loops has been extended to
  58.      handle loops where the body of the loop contains conditional
  59.      code.
  60.  
  61.    + Controls for loop unrolling have been make externally setable
  62.      using the pragmas "ppc_unroll_instructions_limit" and
  63.      "ppc_unroll_factor_limit". The default values for these are:
  64.  
  65.      #pragma ppc_unroll_instructions_limit 100
  66.      #pragma ppc_unroll_factor_limit 10
  67.  
  68.      The factor limit controls the max number of copies of the
  69.      loop body which will be generated. The instruction limit
  70.      controls the total size of the unrolled loop body. (It should
  71.      be noted that even if the limit is 100 the result will normally
  72.      be smaller as other optimizations generally will reduce the size
  73.      of the loop body after it has been unrolled).
  74.  
  75.    + Speculative unrolling, for a detected counting loop, where the
  76.      number of iterations is not a compile time constant but can
  77.      be calculated at runtime, the loop is speculatively unrolled.
  78.      For this to work the loop counter must be a 32 bit value (int,
  79.      long, unsigned int, unsigned long), the body of the loop must
  80.      not contain any conditional code.
  81.  
  82.      This feature can be disabled by using the pragma
  83.      "ppc_unroll_speculative"
  84.  
  85.      #pragma ppc_unroll_speculative off
  86.  
  87.      The unroll factor for speculative unrolling will be a power of
  88.      2 (so if unroll factor limit is 10, it will try 8, 4 and 2).
  89.  
  90.    + Loops containing a single conditional which is loop invariant
  91.      are unswitched:
  92.  
  93.      for (i = init; i < limit; i++) {
  94.          ... pre if statements ...
  95.          if (loop-invariant-expression) {
  96.              ... true statements ...
  97.          } else {
  98.              ... false statements ...
  99.          }
  100.          ... post if statements ...
  101.      }
  102.  
  103.      becomes:
  104.  
  105.      if (loop-invariant-expression) {
  106.         for (i = init; i < limit; i++) {
  107.             ... pre if statements ...
  108.             ... true statements ...
  109.             ... post if statements ...
  110.         }
  111.      } else {
  112.          for (i = init; i < limit; i++) {
  113.              ... pre if statements ...
  114.              ... false statements ...
  115.              ... post if statements ...
  116.          }
  117.      }
  118.  
  119.    + Treat as counting loops those loops where the condition is BNE
  120.      provided the increment is 1 or -1.
  121.  
  122.    + Improve handling of induction variables, detect nested induction
  123.      variables which can be merged
  124.  
  125.      int a[10][10];
  126.  
  127.      for (i = 0; i < 10; i++) {
  128.          for (j = 0; j < 10; j++) {
  129.               a[i][j]
  130.          }
  131.      }
  132.  
  133.      detect that a[i][j] is a single induction variable (instead of
  134.      two (a[i], and a[i][j])). This only works if the loop is over
  135.      all elemements of the first subscript (otherwise the value of
  136.      a[i] needs to be recomputed at the beginning of the inner loop).
  137.  
  138.      Also detect induction variables which are simple offsets from
  139.      each other (like fields of a structure). If possible update
  140.      the load/store instructions to use a single induction variable
  141.      with the offsets encoded into the load/store instruction.
  142.  
  143.    + Extended Constant Propagation to handle ADD => ADDI, OR => ORI,
  144.      SUB => ADDI or SUBFIC (depending on which paramter is constant).
  145.      (These patterns were handled in the peephole, but Constant
  146.      Propagation works across blocks).
  147.  
  148.    + ADDI ... Load/Store; when ever possible the constant part of an
  149.      ADDI is propagated into the Load/Store instruction, and the ADDI
  150.      is defered as late in the basic block as possible. For example
  151.  
  152.      int *p;
  153.  
  154.      *p++ = 0; *p++ = 0; *p++ = 0; *p++ = 0;
  155.  
  156.      Produces something like:
  157.  
  158.      LI        R0,0
  159.      STW    R0,0(Rp)
  160.      ADDI    Rp,Rp,4
  161.      STW    R0,0(Rp)
  162.      ADDI    Rp,Rp,4
  163.      STW    R0,0(Rp)
  164.      ADDI    Rp,Rp,4
  165.      STW    R0,0(Rp)
  166.      ADDI    Rp,Rp,4
  167.  
  168.      This is now optimized to:
  169.  
  170.      LI        R0,0
  171.      STW    R0,0(Rp)
  172.      STW    R0,4(Rp)
  173.      STW    R0,8(Rp)
  174.      STW    R0,12(Rp)
  175.      ADDI    Rp,Rp,12
  176.  
  177.      When possible the last add will be deleted if the value is not live,
  178.      if the value is live and the ADDI can be folded into the last Load
  179.      or Store the update form of the load/store will be used. This general
  180.      optimization will work on other forms (so *--p, *++p etc will be
  181.      handled).
  182.  
  183.    + Peephole optimizer now keeps track of the usage of condition code
  184.      fields so that compares when the result would be constant can be
  185.      removed. In the following example the BEQ can become a "B" or be
  186.      deleted, in addition the CMP (and perhaps the LI) can be deleted
  187.      if their results are not live.
  188.  
  189.      LI Rx,k; CMP[L]I CRx,Rx,l; B[EQ|NE] CRx,label
  190.      ==>
  191.      if branch condition is true:
  192.     B label
  193.      if branch condition is false:
  194.         B nextblock
  195.  
  196.      *Note if the branch is to the next block the final assembly pass
  197.       will optimize the branch away
  198.  
  199.    + Added peephole patterns:
  200.      LBZX Ry,(Rx,Rw); RLWINM Rz,Ry,0,a,31; => LBZX Rz,(Rx,Rw)
  201.      iff a <= 24, and Ry is not live after the RLWINM
  202.  
  203.      LHZX Ry,(Rx,Rw); RLWINM Rz,Ry,0,a,31; => LHZX Rz,(Rx,Rw)
  204.      iff a <= 16, and Ry is not live after the RLWINM
  205.  
  206.      NOT Ry,Rx; AND Rz,Rw,Ry => ANDC Rz,Rw,Rx
  207.      iff Ry is not live after the ADN.
  208.  
  209.    + Extensive improvements for ADDI ... Load/Store patterns
  210.  
  211. ========================================================================
  212. Bugs Fixed in This Version
  213. ========================================================================
  214.  
  215. *  MW09350: Unrolling loops which contain a conditional
  216.    expression which has a "continue" (or no else and code
  217.    after the conditional part of the if):
  218.    
  219.    for (i = 0; i < 4; i++) {
  220.       if (cond || cond) {
  221.       
  222.       }
  223.    }
  224.  
  225. *  MW09249: in constant propagation incorrectly converted
  226.  
  227.    LI Rx,0; ... SUBF Rz,Ry,Rx ===>>> MR Rz,Rx
  228.  
  229.    it should have been
  230.  
  231.    NEG Rz,Rx
  232.  
  233. *  MW09181: counting loop with post decrement (or increment) when
  234.    converting the loop (because it is known that the loop will always
  235.    be executed once) the instructions following the compare where not
  236.    copied into the "preheader".
  237.  
  238. *  MW09120 PowerPlant project won't link with PPC compiler 2.2 build 27
  239.    The optimizer detected an invariant conditional in a loop and
  240.    unswitched the loop, however the loop contained a call (which meant
  241.    that there is little if any improvement with unswitching) and the loop
  242.    was converted in such a way as to confuse the scheduler. The code now
  243.    checks for calls (and instructions with side effects).
  244.  
  245. *  MW09048: Re : BUG - C++ PPC 2.2b1 + optimizations
  246.    Fixed a bug in speculative loop unrolling when the loop counter
  247.    was not 1 and the loop counter is not referenced in the loop body.
  248.  
  249. *  Fixed a bug handling the pattern
  250.    ADD rX,rY,rZ; ADDI rW,rX,0 ==> ADD rW,rY,rZ
  251.  
  252. *  MW08931 Out-of-line traceback tables causes ICE
  253.  
  254. *  MW08861 fixes a bug which prevented disabling puttting small static
  255.    data in the TOC.
  256.  
  257. *  MW08762, MW08727 PPC backend's parser for pragmas was incorrectly
  258.    complaining about missing EOL after unknown pragmas
  259.  
  260. *  MW08761: Incorrect internal error when trying to optimize small
  261.    local arrays to registers.
  262.  
  263. *  MW08611 fixes a bug in structure copy using doubles (when one of the
  264.    operands being copied is an array reference).
  265.  
  266. *  MW08481 fixes a bug in copy propagation which was confusing the offsets
  267.    of parameters (only effects parmeters not passed in registers)
  268.  
  269. *  fixes a bug in global register allocation at optimization level 2
  270.    (with only the global optimizer "Speed" checkbox set). This bug
  271.    only effects C++ functions with a inlined function which has to
  272.    destroy an object in response to an exception (and even then only
  273.    for some rare cases).
  274.  
  275. *  Handle a conditional expression where one of the values is a throw:
  276.  
  277.    var = expr ? value : throw error;
  278.  
  279. *  Fix the parameter types on __memcpy() and __strcpy()
  280.  
  281. *  Handle using !varaible as a paramter so it only generates
  282.    two instructions (instead of 4).
  283.  
  284. ========================================================================
  285. Contacting Metrowerks
  286. ========================================================================
  287.  
  288. For bug reports, technical questions, and suggestions, please use the
  289. forms in the Release Notes folder on the CD, and send them to
  290.  
  291. support@metrowerks.com
  292.  
  293. See the CodeWarrior on the Nets document in the Release Notes folder for
  294. more contact information, including a list of Internet newsgroups,
  295. online services, and patch and update sites.
  296.  
  297. ========================================================================
  298. Bob Campbell, Andy Nicolas
  299. CodeWarrior C/C++ PowerPC Engineering Team
  300. Metrowerks Coporation
  301.